<?php
require('./topsdk/TopSdk.php');

$conf = array(
  'appkey' => '',
  'secret' => '',
  'keyword' => '',
  'page' => 1,
  'cid' => '',
);

$c = new TopClient;
$c->appkey = Config::get('app.appkey');
$c->secretKey = Config::get('app.secret');
$req = new TaobaokeItemsCouponGetRequest;
$req->setKeyword($keyword);
$req->setCouponType($page);
$req->setCid($cid);
$req->setShopType("all");
$field = array('num_iid', 'seller_id', 'nick', 'title', 'price', 'item_location', 'seller_credit_score', 'click_url', 'shop_click_url', 'pic_url', 'taobaoke_cat_click_url', 'keyword_click_url', 'coupon_rate', 'coupon_price', 'coupon_start_time', 'coupon_end_time', 'commission_rate', 'commission', 'commission_num', 'commission_volume', 'volume', 'shop_type');
$req->setFields(implode(',', $field));
$req->setStartCouponRate($start_coupon_rate * 100);
$req->setEndCouponRate($end_coupon_rate * 100);
$req->setPageNo($page);
$req->setPageSize($page_size);
$resp = $c->execute($req);
$products = $resp->taobaoke_items;
